﻿<!DOCTYPE html>
<html>
<head>
   <title>Running Matlab with VI-DriveSim for Windows</title>
   <meta name="generator" content="Help & Manual">
   <meta name="keywords" content="">
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <link type="text/css" href="default.css" rel="stylesheet">
   <link type="text/css" href="custom.css" rel="stylesheet">
   <script type="text/javascript" src="nsh.js"></script>
   
<!-- non-scrolling headers for CHM and browser-based help, local styles-->
<style TYPE="text/css" media="screen"> 
   <!-- 
   body {    
      margin:0; 
      padding:0; 
      overflow: auto; 
      background: #edede9; 
   } 
   #idheader { 
      width:100%; 
      height:auto; 
      padding: 0; 
      margin: 0;     
} 
    #idheaderbg  {
    background: #E40A00; 
}
#idheadernowrap  {
    white-space:nowrap; 
}
    ul {list-style-type: lower-roman}
   -->
   </style>
   
<style TYPE="text/css" MEDIA="print">
<!--
/* Hide navigation links and add space between header
     and text in the printed version. Not valid for eBooks. */
#idnav { display:none;	 }
.topichead { padding: 5px 5px 20px 5px; }
-->
</style>   
   <script type="text/javascript" src="jquery.js"></script>
   <script type="text/javascript" src="helpman_settings.js"></script>
   <script type="text/javascript" src="helpman_topicinit.js"></script>

   <script type="text/javascript">
     HMSyncTOC("index.html", "vbk_tut_running_matlab_with_vi-drivesi.htm");
   </script>
   <script type="text/javascript" src="highlight.js"></script>
   <script type="text/javascript">
     $(document).ready(function(){highlight();});
   </script>
</head>
<body>

<!--ZOOMSTOP-->

<div id="idheader" >
<div id="idheaderbg">
<table width="100%" border="0" cellspacing="0" cellpadding="0" 
       style="margin: 0px; color: #D7D7D7;">

  <tr valign="middle">
    <td align="left" valign="middle" class="topichead">
    <!--<div id="idheadernowrap">-->
    <p class="crumbs" id="idnav"><b>Navigation:</b>&nbsp;
   
   VI-DriveSim 19.2 on Windows &gt; VI-DriveSim 19.2 Tutorials &gt; Running Matlab with VI-DriveSim&nbsp;&gt;</p>
      <h1 class="p_Heading1" style="page-break-after: avoid;"><span class="f_Heading1">Running Matlab with VI-DriveSim on Windows</span></h1>

    <!--</div>-->
    </td>
    <td align="right" width="180" valign="middle" class="topichead" id="idnav">
    <div id="idheadernowrap">
    <a href="javascript: print();"
    		onmouseover="document.images.prntr.src='print_a.png'" 
        onmouseout="document.images.prntr.src='print_n.png'"
        ><img name="prntr" border="0" alt="Print this Topic" title="Print this Topic" src="print_n.png"
        ></a>&nbsp;&nbsp;
     <a href="vbk_tut_performing_a_simulati2_2.htm"
        onmouseover="document.images.prev.src='back_a.png'" 
        onmouseout="document.images.prev.src='back_n.png'"
        ><img name=prev src="back_n.png" border=0 alt="Previous page"
        ></a><a href="drvsim_i_simwb_inst.htm"
        onmouseover="document.images.main.src='top_a.png'" 
        onmouseout="document.images.main.src='top_n.png'"><img name=main src="top_n.png" border=0 alt="Return to chapter overview"
        ></a><a href="vbk_tut_logging_csv_files_with_drivesi.htm"
        onmouseover="document.images.next.src='next_a.png'" 
        onmouseout="document.images.next.src='next_n.png'"><img name=next src="next_n.png" border=0 alt="Next page"
        ></a>
    </div>
    </td>
  </tr>
</table>
</div>

<!-- The following code displays Expand All/Collapse All links  below the header in topics containing toggles -->
  

</div>  



<div id="idcontent"><div id="innerdiv"> 
<!--ZOOMRESTART-->
<p class="p_Normal">If you have a <span style="font-style: italic;">Matlab</span> installation (please refer to VI-CarRealTime documentation in order to know compatible versions) &nbsp;together with VI-DriveSim, then you can run your Simulink models directly from VI-DriveSim. Please, before continue reading, make sure you have read and understood the VI-CarRealTime documentation about how to use <span style="font-style: italic;">Matlab/Simulink</span> models with VI-CarRealTime and <a href="drivesim_setting_up_the_model_in_vi-car.htm" class="topiclink">how to create a vehicle model for VI-DriveSim</a>.</p>
<p class="p_Normal">&nbsp;</p>
<p class="p_Normal" style="text-align: center;"><img alt="drvsim_Matlab_03" width="760" height="646" style="margin:0px auto 0px auto;width:760px;height:646px;border:none" src="drvsim_matlab_03.png"/></p>
<p class="p_Normal">&nbsp;</p>
<p class="p_Normal">&nbsp;</p>
<p class="p_Normal">In order to run your <span style="font-style: italic;">Matlab/Simulink</span> models into VI-DriveSim, you have to follow these steps:</p>
<p class="p_Normal">&nbsp;</p>
<p class="p_Normal">- Copy your <span style="font-style: italic;">Simulink</span> model (.mdl file) and all the files you may need (i.e. .m for defining parameters, etc) into <span style="font-style: italic;">[your installation path]/VI-DriveSim 19/standalone</span></p>
<p class="p_Normal">&nbsp;</p>
<p class="p_Normal">- Manually edit <span style="font-style: italic;">[your installation path]/VI-DriveSim 19/standalone/drivesim_test.m</span></p>
<p class="p_Normal">&nbsp;</p>
<p class="p_Normal">- Call all the <span style="font-style: italic;">Matlab</span> functions you may need (in the example below, only parameters.m is called) and specify which .mdl to run.</p>
<p class="p_Normal">&nbsp;</p>
<p class="p_Normal" style="text-align: center;"><img alt="drvsim_Matlab_01" width="935" height="170" style="margin:0px auto 0px auto;width:935px;height:170px;border:none" src="drvsim_matlab_01.png"/></p>
<p class="p_Normal" style="text-align: center;">&nbsp;</p>
<p class="p_Normal" style="text-align: center;">&nbsp;</p>
<p class="p_Normal">- vicrt_inputfile is the variable needed by <span style="font-style: italic;">Matlab</span> to know which VI-CarRealTime model to load in the mex. You don't have to specify it from here, so please leave it as it is.</p>
<p class="p_Normal">&nbsp;</p>
<p class="p_Normal">- open VI-DriveSim</p>
<p class="p_Normal">&nbsp;</p>
<p class="p_Normal">- select the test <span style="font-style: italic;">drvsim_simulink.bat</span> and pick your VI-CarRealTime model in the field VIDRIVESIM_MODEL (the model must be created from a VI-DriveSim event from VI-CarRealTime and must be present into <span style="font-style: italic;">[your installation path]/VI-DriveSim 19</span>/<span style="font-style: italic;">models</span>/)</p>
<p class="p_Normal">&nbsp;</p>
<p class="p_Normal" style="text-align: center;"><img alt="drvsim_Matlab_02" width="778" height="338" style="margin:0px auto 0px auto;width:778px;height:338px;border:none" src="drvsim_matlab_02.png"/></p>
<p class="p_Normal" style="text-align: center;">&nbsp;</p>
<p class="p_Normal">&nbsp;</p>
<p class="p_Normal">- click on <span style="font-style: italic;">save config</span> and then press the <span style="font-style: italic;">start </span>button, a <span style="font-style: italic;">Matlab</span> shell will appear. Make sure that your model is correctly running.</p>
<p class="p_Normal">&nbsp;</p>
<p class="p_Normal" style="text-align: center;"><img alt="drvsim_Matlab_04" width="794" height="567" style="margin:0px auto 0px auto;width:794px;height:567px;border:none" src="drvsim_matlab_04.png"/></p>
<p class="p_Normal" style="text-align: center;">&nbsp;</p>
<p class="p_Normal">&nbsp;</p>
<p class="p_Normal">- When you have finished your driving session, click on <span style="font-style: italic;">stop </span>to close <span style="font-style: italic;">Matlab</span>. Please note that this command will stops every <span style="font-style: italic;">Matlab</span> session running on your PC.</p>
<p class="p_Normal">&nbsp;</p>
<p class="p_Normal"><span style="font-weight: bold;">PLEASE NOTE:</span> if you want to set some internal activity flags within the VI-CarRealTime inputs, you cannot do it via S<span style="font-style: italic;">imulink</span>, but you have to do it by initializing them in the <span style="font-style: italic;">[your installation path]/VI-DriveSim 19/</span><span style="font-style: italic;">standalone/runrtdb.cmd</span>. Open it with a text editor and set all the initial values in it like in the example below.</p>
<p class="p_Normal">&nbsp;</p>
<p class="p_Normal" style="text-align: center;"><img alt="drvsim_Matlab_05" width="910" height="279" style="margin:0px auto 0px auto;width:910px;height:279px;border:none" src="drvsim_matlab_05.png"/></p>
<p class="p_Normal" style="text-align: center;">&nbsp;</p>
<p class="p_Normal" style="text-align: left;">&nbsp;</p>
<p style="text-align: left; margin: 0px 0px 0px 24px;">You also need to have a look at <a href="drivesim_drivesim_interface.htm" class="topiclink">Disabling VI-CarRealTime_Inputs</a>.</p>
<p class="p_Normal" style="text-align: center;">&nbsp;</p>
<p class="p_Normal" style="text-align: center;">&nbsp;</p>

<!--ZOOMSTOP-->
</div></div>
<script type="text/javascript"> 
<!-- 
var lastSlashPos = document.URL.lastIndexOf("/") >
document.URL.lastIndexOf("\\") ? document.URL.lastIndexOf("/") :
document.URL.lastIndexOf("\\");
if( document.URL.substring( lastSlashPos + 1, lastSlashPos + 4
).toLowerCase() != "~hh" )
{
    nsrInit();
}
--> 
</script> 
</body>
</html>
